<?php

# seat_status_attrib.php

# http://projects:8081/cdapp-2kt-api/api/seat_status_attrib.php

# http://projects:8081/cdapp-2kt-api/api/seat_status_attrib.php?s=ACC05&k=colorDark&v=0099CC

include_once '_portal.php';

$s = isset($_GET['s']) ? $_GET['s'] : null;
$k = isset($_GET['k']) ? $_GET['k'] : null;
$v = isset($_GET['v']) ? $_GET['v'] : null;

$a = ['frequency', 'color', 'defaultColor', 'planningSectorCodes', 'planningFrequency', 'sectorCodes', 'users'];

if (!$s || !$k || !$v) {
  output(['result' => false, 'message' => 'params unset']);
} elseif (!in_array($k, $a)) {
  output(['result' => false, 'message' => 'key invalid']);
} else {
  $sql = "UPDATE `2kt_seat_status` SET `{$k}`='{$v}' WHERE  `seatName`='{$s}'";
  $result = exec_sql($sql);
  if ($result) {
    output(['result' => true, 'message' => "set {$k} = {$v} for seat: {$s}"]);
  } else {
    output(['result' => false, 'message' => 'update failed', 'sql' => $sql]);
  }
}

// frequency, colorDark, colorLight
// UPDATE `2kt_seat_status_acc` SET `frequency`='123.7' WHERE  `seatName`='ACC04'